import { createApp } from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'
import store from './store'


// 1.0 引入全局的样式
import "@/styles/index.scss"

// 2.0 全局的混入 
import { mixins } from './utils/mixins';

// 3.0 element-plus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

// 4.0 全局注册组件 
import LoginByName from "@/views/logins/LoginByName.vue"
import LoginByPhone from "@/views/logins/LoginByPhone.vue"

import moment from "moment"
const app = createApp(App)
// 全局注册过滤器 
app.config.globalProperties.$filters = {
    timeFormat(value,str){
        if(!value) return value;
        str = str || 'YYYY-MM-DD'
        console.log(value)
        return moment(value).format(str)
    },
    telformat(value,str){
        if(!value) return '';
        str = str || '-';
        value = value.toString().split("");
        console.log(value)
        value.splice(3,0,str);
        value.splice(8,0,str);
        return value.join("")
    }
}
// 
// import {ajax} from '@/api'
// Vue.prototype.$ajax = ajax;

app
.component('LoginByName',LoginByName)
.component('LoginByPhone',LoginByPhone)
.use(ElementPlus)
.mixin(mixins)
.use(store)
.use(router)
.mount('#app')
